package com.loan.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.loan.entity.Avaloan;
import com.loan.mapper.AvaloanMapper;
import com.loan.service.AvaloanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
* @author z
* @description 针对表【avaloan】的数据库操作Service实现
* @createDate 2023-04-21 14:51:41
*/
@Service
public class AvaloanServiceImpl extends ServiceImpl<AvaloanMapper, Avaloan> implements AvaloanService {
    @Resource
    private AvaloanMapper avaloanMapper;

    @Override
    public BigDecimal getAvLoan(BigDecimal total) {
        BigDecimal money ;
        //根据房屋总价(total)来计算可贷额度
        if (total==null || total.intValue() <30 ){
            money = BigDecimal.valueOf(0);
        }else if (total.intValue()<=50 && total.intValue() >30){
            money = BigDecimal.valueOf(10);
        }else if (total.intValue()<=100 && total.intValue() >50){
            money = BigDecimal.valueOf(30);
        }else if (total.intValue() <= 150 && total.intValue() >100){
            money = BigDecimal.valueOf(50);
        }else if (total.intValue() <= 200 && total.intValue() >150){
            money = BigDecimal.valueOf(70);
        }else if (total.intValue() <= 250 && total.intValue() >200){
            money = BigDecimal.valueOf(100);
        }else if (total.intValue() <= 300 && total.intValue() >250){
            money = BigDecimal.valueOf(150);
        }else {
            money = BigDecimal.valueOf(total.intValue()/2);
        }
        return money;
    }
}




